char c_text[300] = "";
int c_text_pos = 0;
extern int year,month, day, hour, min, sec;

int c_fp = 0;
int c_sp = 0;


void c_write_floppy(char *cbuff[]);
int strsc(char *a, char *b);
#include <stringp.h> 
#include <funcs.h>
#include <force/floppy3.h>
//from MAIN.C */


void c_text_add(char c)
{


	c_text[c_text_pos] = c;	
	c_text_pos++;
		 
	
}	
	
void c_text_write(void)
{

	int ii;

	read_screen(c_sp, (c_fp - c_sp));	
	kprintf("\n");
//......................................................................


	if (strsc(c_text,"version") == 1)
		kprintf("V0.0.1, (C)2007");
	else if (strsc(c_text,"memlst") == 1)	
		memlst();
	else if (strsc(c_text,"reads") == 1)		
		kprintf("öhh");
	else if (strsc(c_text,"time") == 1)		
		kprintf("%d:%d:%d",hour,min,sec);
	else if (strsc(c_text,"date") == 1)		
		kprintf("%d-%d-%d",day,month,year);	
	else if (strsc(c_text,"devlst") == 1)		
		floppy_ident();	
	else if (strsc(c_text,"cls") == 1) 
			kprintf("\x1B[2J...");
	else if (strsc(c_text,"rr") == 1) 
			readRoot();
	else
	kprintf("*Unknown Command: %s",c_text);
	
	
	
//......................................................................	
	kprintf("\n");
console_start("root");
c_text_pos = 0;

for (ii=0;ii<300;ii++)
	c_text[ii] = NULL;


}


int strsc(char *a, char b[])
{
	int ii = 0;
	int elimit;
	elimit = strlen(b);

	for (ii=0;ii<elimit;ii++)
	{
	//kprintf("\nCondition = %d, expected result = %c, %c\t",ii, a[ii], b[ii]);
		if (a[ii] != b[ii])
		return 0;
	//kprintf("passed\n");	
	}
	
	return 1;
	
}

void console_start(char pref[])
{
kprintf("%s~#",pref);	
	c_sp = (get_x() + (get_y() * 80));
}	

void c_set_fp()
{
	c_fp= (get_x() + (get_y() * 80));	
}


void c_write_floppy(char *cbuff[])
{
	int ii;
	for (ii=0;ii<256;ii++)
	{
	
			if ( ((ii+1)%16) == 1)
			kprintf("\n");
		
			kprintf("%2X",*cbuff[ii]);	
		
	}	
}
